/**
 * 
 */
package com.gosophia.orgManagement.action;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.organizationManagement.dto.OrganizationDTO;
import com.gosophia.organizationManagement.ws.OrganizationManagementWebService;
import com.gosophia.userManagement.dto.UserInfoDTO;
import com.opensymphony.xwork2.ActionContext;

/**
 * 获取机构详细信息用action
 * @author wangxinbing,zhaoyan
 * @since  2010-12-31
 *  Copyright (c) 2010 Gosophia corporation All Rights Reserved
 */
@Controller("GetOrganizationDetailAction")
@Scope("prototype")
public class GetOrganizationDetailAction extends BaseSupportAction {
    private static final long serialVersionUID = 1L;
    @Autowired
    private OrganizationManagementWebService organizationManagementWebService;
    
    
    private Long orgId;
    private OrganizationDTO organizationDTO;
    //联系人
    private List<Long> contactIds;
    
    public String _execute()throws Exception{
        organizationDTO = organizationManagementWebService.findOrgDetailByOrgId(orgId);
        //联系人id
        if(organizationDTO.getContactDTOs()!=null && organizationDTO.getContactDTOs().size()!=0){
            contactIds=new ArrayList<Long>();
            for(UserInfoDTO u:organizationDTO.getContactDTOs()){
                contactIds.add(u.getUserInfoId());
            }
        }

        if(organizationDTO!=null){
            super.getRequestResult().setRsltCode("0");
        }else{
            super.getRequestResult().setRsltCode("1");
            super.getRequestResult().setMessage("该机构已被修改，请刷新页面重新操作，JC2_ORG_B_2");
        }

        return SUCCESS;       
        
    }

//    @Override
//    public RequestResult getRequestResult() {
//        return requestResult;
//    }

    public Long getOrgId() {
        return orgId;
    }

    public void setOrgId(Long orgId) {
        this.orgId = orgId;
    }

    public OrganizationDTO getOrganizationDTO() {
        return organizationDTO;
    }

    public void setOrganizationDTO(OrganizationDTO organizationDTO) {
        this.organizationDTO = organizationDTO;
    }

    public List<Long> getContactIds() {
        return contactIds;
    }

    public void setContactIds(List<Long> contactIds) {
        this.contactIds = contactIds;
    }
    
}
